"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var BaseDao_1 = require('./BaseDao');
var UsersDao = (function (_super) {
    __extends(UsersDao, _super);
    function UsersDao() {
        _super.call(this);
        this.userModel = this.dbManager.getModel("mUser");
    }
    UsersDao.prototype.add = function (user, callback) {
        var user_ = new this.userModel(user);
        user_.save(callback);
    };
    UsersDao.prototype.get = function (username, password, callback) {
        this.userModel.findOne({ username: username, password: password }, callback);
    };
    UsersDao.prototype.update = function (user, callback) {
        var _this = this;
        var query = { _id: user._id };
        var updater = {
            nickname: user.nickname,
            password: user.password,
            avatar: user.avatar
        };
        this.userModel.update(query, updater, function () {
            _this.userModel.findById(user._id, callback);
        });
    };
    return UsersDao;
}(BaseDao_1.BaseDao));
exports.UsersDao = UsersDao;
